package p08.p0802;

/**
 * Created by wy on 7/17/2017.
 */

//查找数组中的最大值
public class ArrayTool {

    public static int getMax(int arr[]) {
        int Max = arr[0];
        for (int i = 1; i < arr.length; i++) {
            if (arr[i] > Max) {
                Max = arr[i];
            }
        }
        return Max;
    }

    //遍历数组，查找数组中的某个值
    public static int getIndex(int[] arr, int index) {

        int a = -1;

        for (int i = 0; i <= arr.length - 1; i++) {
            System.out.println(arr[i]);
            if (index == arr[i]) {
                //  System.out.println("...");
                a = arr[i];
            }
        }
        return a;

    }
}